#include"Stack.h"
bool isValid(char* s)
{
	ST st;
	STInit(&st);
	while (*s)
	{
		if (*s == '(' || *s == '{' || *s == '[')
		{
			STPush(&st, *s);
		}
		else
		{
			if (STEmpty(&st))
			{
				STDestroy(&st);
				return false;
			}
			char top = STTop(&st);
			STPop(&st);
			if ((top == '(' && *s != ')')
			|| (top == '[' && *s != ']')
			|| (top == '{' && *s != '}'))
			{
				STDestroy(&st);
				return false;
			}
		}
		s++;
	}
	if (!STEmpty(&st))
	{
		STDestroy(&st);
		return false;
	}
	return true;
}
int main()
{
	char s[] = "({}{}";
	bool ret = isValid(s);
	printf("%d", ret);
	return 0;
}